package generic;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;

/**
 * todo
 *
 * @author: luolidong
 * @create: 2021-07-14 20:15
 * @version: 1.0
 */
public class Demo2 {

    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        List<String> list = new ArrayList<>();
        list.add("test");

        Method add = list.getClass().getMethod("add", Object.class);

        add.invoke(list,11L);
        add.invoke(list,11.01);

        for(Object o:list){
            System.out.println(o);
        }
        System.out.println("list.get(1) = " + list.get(1));
//        System.out.println("list.get(2) = " + list.get(2));
//        System.out.println("list.get(3) = " + list.get(3));
    }
}
